package com.wangshang.general.commodity.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wangshang.general.commodity.po.CommodityNorm;

/**
 * A data access object (DAO) providing persistence and search support for
 * CommodityNorm entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.wangshang.general.commodity.po.CommodityNorm
 * @author MyEclipse Persistence Tools
 */

public class CommodityNormDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(CommodityNormDAO.class);
	// property constants
	public static final String NORM_NAME = "normName";
	public static final String NORM_VALUE1 = "normValue1";
	public static final String NORM_VALUE2 = "normValue2";
	public static final String NORM_VALUE3 = "normValue3";
	public static final String NORM_VALUE4 = "normValue4";
	public static final String NORM_VALUE5 = "normValue5";
	public static final String NORM_VALUE6 = "normValue6";
	public static final String NORM_VALUE7 = "normValue7";
	public static final String NORM_VALUE8 = "normValue8";
	public static final String NORM_VALUE9 = "normValue9";
	public static final String NORM_VALUE10 = "normValue10";
	public static final String NORM_VALUE11 = "normValue11";
	public static final String NORM_VALUE12 = "normValue12";
	public static final String NORM_VALUE13 = "normValue13";
	public static final String NORM_VALUE14 = "normValue14";
	public static final String NORM_VALUE15 = "normValue15";
	public static final String NORM_VALUE16 = "normValue16";
	public static final String NORM_VALUE17 = "normValue17";
	public static final String NORM_VALUE18 = "normValue18";
	public static final String NORM_VALUE19 = "normValue19";
	public static final String NORM_VALUE20 = "normValue20";
	public static final String NORM_VALUE21 = "normValue21";
	public static final String NORM_VALUE22 = "normValue22";
	public static final String NORM_VALUE23 = "normValue23";
	public static final String NORM_VALUE24 = "normValue24";

	protected void initDao() {
		// do nothing
	}

	public void save(CommodityNorm transientInstance) {
		log.debug("saving CommodityNorm instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(CommodityNorm persistentInstance) {
		log.debug("deleting CommodityNorm instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public CommodityNorm findById(java.lang.Long id) {
		log.debug("getting CommodityNorm instance with id: " + id);
		try {
			CommodityNorm instance = (CommodityNorm) getHibernateTemplate()
					.get("com.wangshang.general.commodity.CommodityNorm", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(CommodityNorm instance) {
		log.debug("finding CommodityNorm instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding CommodityNorm instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from CommodityNorm as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByNormName(Object normName) {
		return findByProperty(NORM_NAME, normName);
	}

	public List findByNormValue1(Object normValue1) {
		return findByProperty(NORM_VALUE1, normValue1);
	}

	public List findByNormValue2(Object normValue2) {
		return findByProperty(NORM_VALUE2, normValue2);
	}

	public List findByNormValue3(Object normValue3) {
		return findByProperty(NORM_VALUE3, normValue3);
	}

	public List findByNormValue4(Object normValue4) {
		return findByProperty(NORM_VALUE4, normValue4);
	}

	public List findByNormValue5(Object normValue5) {
		return findByProperty(NORM_VALUE5, normValue5);
	}

	public List findByNormValue6(Object normValue6) {
		return findByProperty(NORM_VALUE6, normValue6);
	}

	public List findByNormValue7(Object normValue7) {
		return findByProperty(NORM_VALUE7, normValue7);
	}

	public List findByNormValue8(Object normValue8) {
		return findByProperty(NORM_VALUE8, normValue8);
	}

	public List findByNormValue9(Object normValue9) {
		return findByProperty(NORM_VALUE9, normValue9);
	}

	public List findByNormValue10(Object normValue10) {
		return findByProperty(NORM_VALUE10, normValue10);
	}

	public List findByNormValue11(Object normValue11) {
		return findByProperty(NORM_VALUE11, normValue11);
	}

	public List findByNormValue12(Object normValue12) {
		return findByProperty(NORM_VALUE12, normValue12);
	}

	public List findByNormValue13(Object normValue13) {
		return findByProperty(NORM_VALUE13, normValue13);
	}

	public List findByNormValue14(Object normValue14) {
		return findByProperty(NORM_VALUE14, normValue14);
	}

	public List findByNormValue15(Object normValue15) {
		return findByProperty(NORM_VALUE15, normValue15);
	}

	public List findByNormValue16(Object normValue16) {
		return findByProperty(NORM_VALUE16, normValue16);
	}

	public List findByNormValue17(Object normValue17) {
		return findByProperty(NORM_VALUE17, normValue17);
	}

	public List findByNormValue18(Object normValue18) {
		return findByProperty(NORM_VALUE18, normValue18);
	}

	public List findByNormValue19(Object normValue19) {
		return findByProperty(NORM_VALUE19, normValue19);
	}

	public List findByNormValue20(Object normValue20) {
		return findByProperty(NORM_VALUE20, normValue20);
	}

	public List findByNormValue21(Object normValue21) {
		return findByProperty(NORM_VALUE21, normValue21);
	}

	public List findByNormValue22(Object normValue22) {
		return findByProperty(NORM_VALUE22, normValue22);
	}

	public List findByNormValue23(Object normValue23) {
		return findByProperty(NORM_VALUE23, normValue23);
	}

	public List findByNormValue24(Object normValue24) {
		return findByProperty(NORM_VALUE24, normValue24);
	}

	public List findAll() {
		log.debug("finding all CommodityNorm instances");
		try {
			String queryString = "from CommodityNorm";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public CommodityNorm merge(CommodityNorm detachedInstance) {
		log.debug("merging CommodityNorm instance");
		try {
			CommodityNorm result = (CommodityNorm) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(CommodityNorm instance) {
		log.debug("attaching dirty CommodityNorm instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(CommodityNorm instance) {
		log.debug("attaching clean CommodityNorm instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static CommodityNormDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (CommodityNormDAO) ctx.getBean("CommodityNormDAO");
	}
}